package com.zzptc.zzj.a11302huatu;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private LineChart lineChart;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lineChart=findViewById(R.id.line_Chart);
        ArrayList<Entry> list=new ArrayList<>();
        list.add(new Entry(1,3));
        list.add(new Entry(2,8));
        list.add(new Entry(3,6));
        list.add(new Entry(4,3));
        list.add(new Entry(5,5));
        ArrayList<Entry> list1=new ArrayList<>();
        list1.add(new Entry(1,6));
        list1.add(new Entry(2,9));
        list1.add(new Entry(3,4));
        list1.add(new Entry(4,7));
        list1.add(new Entry(5,2));
        LineDataSet lineDataSet=new LineDataSet(list,null);
        lineDataSet.setColor(Color.BLUE);
        LineDataSet lineDataSet1=new LineDataSet(list1,null);
        lineDataSet.setColor(Color.RED);

        ArrayList<ILineDataSet> lineData2=new ArrayList<>();
        lineData2.add(lineDataSet);
        lineData2.add(lineDataSet1);
        //LineData lineData=new LineData(lineData2);
        LineData lineData=new LineData(lineData2);
       // LineData lineData1=new LineData(lineDataSet1);

        lineChart.setData(lineData);

        XAxis xAxis=lineChart.getXAxis();

        //xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    }
}
